import pytest
import requests

from config import readconfig # 获取config配置文件信息(URL、timeout)
readcon=readconfig.Read() # 实例化调用
# cc=readcon.get_crm("curl")
# print(cc)

# 封装crm系统的登录方法
@pytest.fixture(scope="session")
def testcrm():
    date =  {"username": "15510064830","password":"Yjqdd951016"}  # 上传登录参数
    url = readcon.get_crm("curl")  # 从配置文件里面获取请求的url(http://39.106.51.187:8080)
    time = readcon.get_crm("timeout") # 从配置文件里面获取请求的时间
    # url = #url=http://182.92.197.48:8082
    # url+login=http://182.92.197.48:8082/login
    c = requests.post(url+"/login",data=date,timeout=int(time))
    #print(c.json())
    ctoken = c.json()['Admin-Token'] # 获取token
    #print(ctoken)
    return ctoken
#testcrm()
